package com.rms.server.Preprocessing;

import jakarta.annotation.Resource;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;

@Component
public class Preprocess implements CommandLineRunner {
    // 使用Redis
    @Resource
    private RedisTemplate<String, Object> redisTemplate;
    @Value("${_server.CustomizeName.BootTime}")
    String BootTimeKey;

    @Override
    public void run(String... args) throws Exception {
        Logger logger = LogManager.getLogger();
        logger.info("-------------------------------");
        logger.info("--------------Boot!------------");
        logger.info("----------duxingmengshou-------");
        logger.info("------------2024/6/23----------");
        logger.info("----------   /\\_/\\  -----------");
        logger.info("----------  ( o.o )   ---------");
        logger.info("----------   > ^ <    ---------");
        logger.info("-------------------------------");
        SimpleDateFormat sdf = new SimpleDateFormat();// 格式化时间
        sdf.applyPattern("yyyy-MM-dd HH:mm:ss");
        Date date = new Date();// 获取当前时间
        redisTemplate.opsForValue().set(BootTimeKey, sdf.format(date));
    }
}